package com.zhihuiweijian.demo.controller;
import com.zhihuiweijian.demo.model.Hospital;
import com.zhihuiweijian.demo.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("hospital")
@Api(tags={"医院操作接口"})
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;


    @ApiOperation(value="添加医院信息", notes="n",produces = "application/json")
    @GetMapping(value="/addHospital")
    public Map<String, Object> add(Hospital report) {
        Map<String, Object> map = new HashMap();
        try {
            hospitalService.insert(report);
            map.put("state", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("state", false);
            map.put("msg", "添加失败!");
        }
        return map;
    }









    @ApiOperation(value="查询医院信息", notes="n",produces = "application/json")
    @GetMapping(value="/findAllHospital")
    public Map<String,Object> findAllGood() {
        Map<String, Object> map = new HashMap();
        try {
            List<Hospital> reports = hospitalService.findAll();
            map.put("state", true);
            map.put("data",reports);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("state", false);
            map.put("msg", "查询失败!");
        }
        return map;
    }



}
